<template>
  <div>
    <el-table :data="mList" style="width: 100%">
      <el-table-column prop="username" label="用户编号" width="180">
      </el-table-column>
      <el-table-column prop="username" label="用户名" width="180">
      </el-table-column>
      <el-table-column prop="rolename" label="所属属性"> </el-table-column>
      <el-table-column prop="status" label="状态">
        <template slot-scope="obj">
          <el-button type="success" v-if="obj.row.status == 1" round
            >启用</el-button
          >
          <el-button type="danger" v-else round>禁用</el-button>
        </template>
      </el-table-column>
      <el-table-column label="操作">
        <template slot-scope="obj">
          <el-button
            type="primary"
            icon="el-icon-edit"
            circle
            @click="updataMauser(obj.row.uid)"
          ></el-button>
          <el-button
            type="danger"
            icon="el-icon-delete"
            circle
            @click="delManUser(obj.row.uid)"
          ></el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- 分页 -->
    <!-- 分页控件
         total:总的记录个数 
         page-size：每页要显示的个数
         current-change：单击某个页数要触发的事件
     -->
    <el-pagination
      background
      :page-size="size"
      layout="prev, pager, next"
      @current-change="pagelist"
      :total="total"
    >
    </el-pagination>
  </div>
</template>

<script>
import { userCount, userDelete } from "../../request/api.js";
import { successMsg, failedMsg } from "../../tools/tools.js";

export default {
  //接收父组件传过来的管理员列表信息、每页展示几条数据
  props: ["mList", "size",'total'],
  data() {
    return {
    
    };
  },
  mounted() {

  },
  methods: {
    pagelist(curpage) {
      //查询用户单击的页码的内容
      this.$emit("getcurpagelist", curpage);
    },
    updataMauser(id) {
      this.$emit("updateManuser", id);
    },
    delManUser(uid) {
      this.$confirm("此操作将永久删除, 是否继续?", "提示", {
        confirmButtonText: "确定",
        cancelButtonText: "取消",
        type: "warning",
      })
        .then(() => {
          userDelete({ uid })
            .then((d) => {
              if (d.data.code == 200) {
                //删除成功
                successMsg("删除成功");
                this.$emit("delMan");
         
              }
            })
            .catch((e) => {
              console.log(e);
            });
        })
        .catch((e) => {});
    },
  },
};
</script>

<style>
.cell {
  text-align: center !important;
}
.el-pagination {
  margin-top: 40px;
  text-align: center;
}
</style>